<?php
if (!defined('IN_XLP')) {
	exit('Access Denied');
}
$Document = array(
	'pageid'   => 'goods-cateAdd', //页面标示
	'pagename' => '分类添加', //当前页面名称
	'mycss'	   => array(), //加载的css样式表
	'myjs'	   => array(), //加载的js脚本
	'footerjs' => array('content/fuelux/fuelux', 'content/combodate/moment.min'),
	'head'	   => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<style>
#spec_values{width:672px;margin-right:-100px;}
#spec_values input{float:left;width:40%;margin-bottom:15px}
</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
<section id="content">
	<section class="main padder">
		<div class="clearfix">
			<h4><i class="fa fa-edit"></i>规格新增</h4>
		</div>
		<div class="row">
			<div class="col-sm-12">
				<section class="panel">
					<div class="panel-body">
						<form class="form-horizontal" id="specAddForm" method="post" autocomplete="on">
							
							<div class="form-group">
								<label class="col-sm-1 control-label">规格名称</label>
								<div class="col-sm-2">
									<input type="text" name="spec_name" id="spec_name" placeholder="颜色" class="form-control" data-required="true" />
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-1 control-label">规格值</label>
								<div class="col-sm-2" id="spec_values">
									<input type="text" name="spec_value[]" placeholder="（可选）红色" class="form-control" value="">
									<input style="margin-left:20px;" type="text" name="spec_tips[]" placeholder="（可选）简单备注，30字以内" class="form-control" value="">
								</div>
								<button id="addmore" type="button" class="btn btn-white">添加更多</button>
							</div>

							<div class="form-group">
								<label class="col-sm-1 control-label">排序</label>
								<div class="col-sm-2">
									<input type="text" name="spec_sort" placeholder="" class="form-control" value="255">
								</div>
							</div>

							<div class="form-group">
								<div class="col-sm-9 col-lg-offset-1">
									<div class="col-sm-1">
										<button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button>
									</div>
									<button type="button" class="btn btn-white">取消</button>
								</div>
							</div>

						</form>
					</div>
				</section>
			</div>
		</div>
	</section>
</section>
<!--/ content --> 
<!--主体 结束-->
<script>
$(function(){
	var $sp_val = $('#spec_values');
	var input   = $sp_val.html();
	$('#addmore').click(function(){
		$sp_val.append(input);
	});
	$('#specAddForm').submit(function(){
		if( $.trim($('#spec_name').val()) == '' ) {
			Msg.error('请输入规格名称');
			resetSubmit("#sub-ok",'提交');
			return false;
		}
        Msg.loading();
		$.post('<?php echo U("goods/specadd"); ?>', $(this).serialize(), function(json){
			Msg.hide();
			resetSubmit("#sub-ok",'提交');
			if(json.err) {
				Msg.error(json.msg);
			} else {
				Msg.ok(json.msg);
			}
		}, 'JSON');
		return false;
	});
});
</script>
<?php include getTpl('footer', 'public'); ?>